﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using MBWebService.Core.Enums;
using MediaBrowser.Library.Entities;
using System;
using System.Linq;

namespace MBWebService.Core.Classes
{
    [DataContract]
    public class BasicCollectionItem : BasicItem
    {
        public BasicCollectionItem(BaseItem item)
        : base (item) 
        {
            Folder bob = item as Folder;
            Children = bob.Children.ToBasicEnumerable();
            Type = MediaTypes.Folder;
            UnwatchedCount = bob.UnwatchedCount;
        }

        public BasicCollectionItem(IEnumerable<BasicItem> children)
        {
            Children = children;
            Type = MediaTypes.Folder;
            Id = Guid.Empty;
            this.DateCreated = DateTime.Now;
            this.UnwatchedCount = children.Count();     
        }

        [DataMember]
        public IEnumerable<BasicItem> Children { get; set; }

        [DataMember(EmitDefaultValue=false)]
        public int UnwatchedCount { get; set; }

    }
}
